﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using VINETLIFE.AdminCP;
using VINETLIFE.BL;
using VINETLIFE.DO;

namespace VINETLIFE.AdminCP
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                thongkedonhang();
        }
        public void thongkedonhang()
        {
            try
            {
                //theo ngày
                DataTable dt = new DataTable();
                dt = new cmsOrdersBL().SelectTotalOrderNew(1);
                lblNew.Text = dt.Rows[0]["IDNEW"].ToString();
                lblCompleted.Text = dt.Rows[0]["IDCOMPLETED"].ToString();
                lblCancelCustomer.Text = dt.Rows[0]["IDCANCELCUSTOMER"].ToString();
                lblCancelSystem.Text = dt.Rows[0]["IDCANCELSYSTEM"].ToString();
                if (dt.Rows[0]["ToTalVinet"].ToString() != "")
                    lblToTalVinet.Text = string.Format("{0:0,##}",dt.Rows[0]["ToTalVinet"]) + " đ";
                else lblToTalVinet.Text = "0 đ";
                if (dt.Rows[0]["ToTal"].ToString() != "")
                    lblTotal.Text = string.Format("{0:0,##}",dt.Rows[0]["ToTal"]) + " đ";
                else lblTotal.Text = "0 đ";
                //theo tuần
                DataTable dt1 = new DataTable();
                dt1 = new cmsOrdersBL().SelectTotalOrderNew(2);
                lblNewTuan.Text = dt1.Rows[0]["IDNEW"].ToString();
                lblCompletedTuan.Text = dt1.Rows[0]["IDCOMPLETED"].ToString();
                lblCancelCustomerTuan.Text = dt1.Rows[0]["IDCANCELCUSTOMER"].ToString();
                lblCancelSystemTuan.Text = dt1.Rows[0]["IDCANCELSYSTEM"].ToString();
                if (dt1.Rows[0]["ToTalVinet"].ToString() != "")
                    lblToTalVinetTuan.Text = string.Format("{0:0,##}",dt1.Rows[0]["ToTalVinet"]) + " đ";
                else lblTotalTuan.Text = "0 đ";
                if (dt1.Rows[0]["ToTal"].ToString() != "")
                    lblTotalTuan.Text = string.Format("{0:0,##}",dt1.Rows[0]["ToTal"]) + " đ";
                else lblTotalTuan.Text = "0 đ";
                //theo tháng
                DataTable dt2 = new DataTable();
                dt2 = new cmsOrdersBL().SelectTotalOrderNew(3);
                lblNewThang.Text = dt2.Rows[0]["IDNEW"].ToString();
                lblCompletedThang.Text = dt2.Rows[0]["IDCOMPLETED"].ToString();
                lblCancelCustomerThang.Text = dt2.Rows[0]["IDCANCELCUSTOMER"].ToString();
                lblCancelSystemThang.Text = dt2.Rows[0]["IDCANCELSYSTEM"].ToString();
                if (dt2.Rows[0]["ToTalVinet"].ToString() != "")
                    lblToTalVinetThang.Text = string.Format("{0:0,##}",dt2.Rows[0]["ToTalVinet"]) + " đ" ;
                else lblToTalVinetThang.Text = "0 đ";
                if (dt2.Rows[0]["ToTal"].ToString() != "")
                    lblTotalThang.Text = string.Format("{0:0,##}",dt2.Rows[0]["ToTal"]) + " đ";
                else lblTotalThang.Text = "0 đ";
            }
            catch
            { }
        }
    }
}